<!DOCTYPE html>
<html>
<head>
<script src="../../resources/js-test.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script>
description('Test Promise native then.');

window.jsTestIsAsync = true;

var resolve;
var promise = new Promise(function(r) { resolve = r; });
var newPromise = internals.addOneToPromise(promise);

newPromise.then(function(result) {
    window.result = result;
    shouldBe('result', '11');
    return internals.addOneToPromise(result);
}).then(function(result) {
    window.result = result;
    shouldBe('result', '12');
    testPassed('DONE');
}, function() {
    testFailed("rejected");
}).then(finishJSTest, finishJSTest);

resolve(new Promise(function(resolve) { resolve(10); }));

</script>
</body>
</html>
